﻿/*
* Copyright 2009-2010 AKABANA.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
* either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Akabana.Amf.Messaging.Data
{

    /**
     * <summary>リモーティングメッセージボディ</summary>
     * 
     */
    public class AmfMessageBody
    {

        private const string ON_RESULT = "/onResult";

        private const string ON_STATUS = "/onStatus";

        private const string RESPONSE_EMPTY = "";

        /**
         * <summary>リモーティングメッセージボディの生成する</summary>
         * <param Name="responce">ターゲット</param>
         * <param Name="target">レスポンス</param>
         * <returns>リモーティングメッセージボディ</returns>
         */
        public static AmfMessageBody CreateInstance(string target,string responce)
        {
            AmfMessageBody result = new AmfMessageBody();
            result.target = target;
            result.response = responce;
            return result;
        }

        /**
         * <summary>データ</summary>
         */
        public object data { get; set; }

        /**
         * <summary>レスポンス</summary>
         */
        public string response { get; private set; }

        /**
         * <summary>ターゲット</summary>
         */
        public string target { get; private set; }

        private AmfMessageBody()
        {
        }

        /**
         * <summary>結果レスポンスを生成する</summary>
         * <returns>リモーティングメッセージボディ</returns>
         */
        public AmfMessageBody CreateResultResponse()
        {
            AmfMessageBody result = new AmfMessageBody();
            result.target = this.response + ON_RESULT;
            result.response = RESPONSE_EMPTY;
            result.data = null;
            return result;
        }

        /**
         * <summary>障害レスポンスを生成する</summary>
         * <returns>リモーティングメッセージボディ</returns>
         */
        public AmfMessageBody CreateStatusResponse()
        {
            AmfMessageBody result = new AmfMessageBody();
            result.target = this.response + ON_STATUS;
            result.response = RESPONSE_EMPTY;
            result.data = null;
            return result;
        }
    }
}
